//类型别名
type mystr = string | number | boolean
let str:mystr = true
console.log(str);
type myarr = Array<string| number | boolean>
let arr: myarr = ['sf', 12, true]
console.log(arr);


//函数
function add(x: number, y: number): number{
       return x+y
   }
add(2,4)
//可选参数
const fn = (a?: number, b?: number) => {
    console.log('a:'+a,'b:'+b);
    
}
fn(10)

type Myfn = (x: number, y: number) => number
let add1: Myfn = (x, y) =>
{
    return x+y
 }
add1(2,6)
//没有返回值
function print(uname: string): void{
    console.log(uname);
    
}
print('lihua')



export{}